/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.message.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.google.common.collect.Lists;

/**
 * 系统提示信息Entity
 * @author lvbo
 * @version 2013-07-16
 */
@Entity
@Table(name = "system_notify_message")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class SystemNotifyMessage extends BaseEntity {
	public static final int COMPANY_TYPE = 0;//公司通知
	
	private static final long serialVersionUID = 1L;
	private Long id; 		// 编号
	private Date beginDate;	// 消息的有效开始日期
	private Date endDate;	// 消息的有效终止日期
	private String messageContent;	//消息内容
	private int type;	//消息类型：0 - 公司通知1 - 系统升级2 - 短信余额提醒
	
	private List<SystemNotifyMessageDetail> detailList = Lists.newArrayList();
	
	public SystemNotifyMessage() {
		this.type = -1;
	}

	public SystemNotifyMessage(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name="begin_date")
	public Date getBeginDate() {
		return beginDate;
	}

	public void setBeginDate(Date beginDate) {
		this.beginDate = beginDate;
	}

	@Column(name="end_date")
	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	@Column(name="message_content")
	public String getMessageContent() {
		return messageContent;
	}

	public void setMessageContent(String messageContent) {
		this.messageContent = messageContent;
	}
	
	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}
	
	@OneToMany(cascade=CascadeType.ALL,fetch=FetchType.LAZY,mappedBy="systemNotifyMessage")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<SystemNotifyMessageDetail> getDetailList() {
		return detailList;
	}

	public void setDetailList(List<SystemNotifyMessageDetail> detailList) {
		this.detailList = detailList;
	}
}